package com.simple.elpmobile.onlinecase;

import java.io.File;

import com.simple.elpmobile.onlinecase.engine.AppEngine;
import com.simple.elpmobile.onlinecase.utils.ImageLoadUtil;



import android.app.Application;
import android.content.Context;
import android.os.Environment;
import android.os.Handler;

public class ThisApplication extends Application
{
	

	public static String APP_PATH = null;
	
	public static Handler playServiceHandler;	
	
	
	public void onCreate()
	{
		super.onCreate();
		
		initApp();
		initImageLoader(getApplicationContext());

	}


	private void createAppPath() {
		APP_PATH = Environment.getExternalStorageDirectory().getPath()
				+ File.separator + "iflytek" + File.separator
				+ this.getPackageName();
		
		File f = new File(APP_PATH);
		if (f != null & !f.exists()) {
			f.mkdirs();
		}


	}
	
	private void initApp() {

		createAppPath();
		AppEngine.getInstance().setApplication(this);
		
		
		/*CrashHandler crashHandler = CrashHandler.getInstance();
		crashHandler.init(this);*/
		
	}
	

	
	private void initImageLoader(Context context) {
		
		ImageLoadUtil.initImageLoad(context, APP_PATH + "/imageloader/Cache");
	
	}

	public static void setPlayServiceHandler(Handler handler) {
		playServiceHandler = handler;
	}

	public static Handler getPlayServiceHandler() {
		return playServiceHandler;
	}


}
